# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  def tidy_up(class_name)
    class_name.tableize.humanize.singularize.downcase
  end

  def no_model_found(class_name)
    "<li>No #{tidy_up(class_name)} found.</li>"
  end

  def no_model_found_list(class_name)
    "<ul id=\"#{class_name.underscore}_list\" class=\"definition_list\">#{no_model_found(class_name)}</ul>"
  end

  def icon_image_tag(icon, options = {})
    alt_txt = File.basename(icon, File.extname(icon)).titleize
    image_tag(File.join('icons', icon), 
              :border => 0, :size => (options[:size] || "25x25"),
              :alt => alt_txt)
  end

  def has_edit_permission?(user, object)
    object.user_id == user.id
  end

end
